package com.zide.member.controller.community;

import com.zide.common.core.domain.CommonResult;
import com.zide.member.service.community.CommunityCommentService;
import com.zide.member.vo.save.community.CommunityCommentSaveVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import static com.zide.common.core.domain.CommonResult.getResult;
import static com.zide.common.core.domain.CommonResult.success;

/**
 * @author 石添
 * @date 2024/8/24
 */
@Slf4j
@RestController
@RequestMapping("community/comment")
@Tag(name = "会员管理")
@RequiredArgsConstructor
public class CommunityCommentController {

    private final CommunityCommentService communityCommentService;

    /**
     * 发布评论
     */
    @PostMapping("publish")
    public CommonResult publishComment(@RequestBody CommunityCommentSaveVO saveVO) {
        return getResult(communityCommentService.publishComment(saveVO));
    }

    /**
     * 获取文章评论列表
     */
    @GetMapping("essay/{essayId}")
    public CommonResult searchEssayCommentList(@PathVariable("essayId") Long essayId) {
        return success(communityCommentService.searchEssayCommentList(essayId));
    }

    /**
     * 删除文章评论
     */
    @DeleteMapping
    public CommonResult removeComment(@RequestBody Long[] ids) {
        return getResult(communityCommentService.removeComment(ids));
    }

}
